//
//  HMHomeGuessLikeCell.m
//  HowToDo
//
//  Created by 胡坤 on 2017/1/4.
//  Copyright © 2017年 KY. All rights reserved.
//

#import "HMHomeGuessLikeCell.h"
#import "HTDGuessLike.h"
#import "HMHomeCommanLayOut.h"
#import "HMHomeGuessLikeCollectionCell.h"
@interface HMHomeGuessLikeCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property(nonatomic,strong)UICollectionView *guessLikeMainCollection;
@end
NSString* cellId = @"guessLikeMainCollectionCellID";

@implementation HMHomeGuessLikeCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUPUI];
    }
    return self;
}
- (void)setUPUI
{
    [self.contentView addSubview:self.guessLikeMainCollection];
    self.guessLikeMainCollection.backgroundColor = [UIColor whiteColor];
    self.guessLikeMainCollection.dataSource = self;
    self.guessLikeMainCollection.delegate = self;
    [self.guessLikeMainCollection registerNib:[UINib nibWithNibName:@"HMHomeGessLikeCollectionCell" bundle:nil] forCellWithReuseIdentifier:cellId];
    [self.guessLikeMainCollection mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.left.right.offset(0);
         make.height.offset(150);
         make.bottom.equalTo(self.contentView);
     }];
}
#pragma mark -- dataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.guessYouLikes.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
   HMHomeGuessLikeCollectionCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
    
    cell.guessLike = self.guessYouLikes[indexPath.item];
    
    return cell;
}
#pragma mark --delegate 
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    self.selectedItemCallBack(indexPath);
}
- (UICollectionView *)guessLikeMainCollection
{
    if (!_guessLikeMainCollection)
    {
        HMHomeCommanLayOut *layOut = [[HMHomeCommanLayOut alloc]init];
        _guessLikeMainCollection = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layOut];
    }
    return _guessLikeMainCollection;
}





- (void)setGuessYouLikes:(NSArray <HTDGuessLike *>*)guessYouLikes
{
    _guessYouLikes = guessYouLikes;
    

    [self.guessLikeMainCollection reloadData];

}


@end
